﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DataAnnotationsExtensions;
using System.ComponentModel;
using Hetang.Models.Config;

namespace Hetang.Models.Classes
{
    public class dt_Job
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Recruit { get; set; }
    }

    public class dt_Login
    {
        [Required]
        [DisplayName("邮箱")]       
        [Email(ErrorMessage="邮箱格式不正确！")]        
        public string email { get; set; }

        [Required]
        [DisplayName("密码")] 
        [StringLength(16, MinimumLength = 6, ErrorMessage = "密码长度6-16位。")]
        public string password { get; set; }

        [Display(Name = "记住我?（一个月内免登录）")]
        public bool remember { get; set; }
    }

    public class dt_Signup
    {
        [DisplayName("昵称")]
        [Required]
        [RegularExpression("^[\u4E00-\u9AF5\uf900-\ufa2da-zA-Z0-9]{3,10}$", ErrorMessage = "只支持中、英文，3-10个字符。")]
        [Remote("UsernameIsExist", "check", ErrorMessage = "这个昵称已经被注册了。")]
        public string username { get; set; }

        [DisplayName("密码")]
        [Required]
        [StringLength(16, MinimumLength = 6, ErrorMessage = "密码长度6-16位。")]
        public string password { get; set; }

        [DisplayName("确认密码")]
        [Required]
        [Compare("password", ErrorMessage = "两次输入的密码不一致。")]
        public string password2 { get; set; }

        [DisplayName("邮箱")]
        [Required]
        [Email(ErrorMessage = "邮箱格式不正确。")]
        [Remote("EmailIsExist", "check", ErrorMessage = "这个邮箱地址已经被注册了。")]
        public string email { get; set; }

        private string _usertype;

        [DisplayName("用户类型")]
        [Required]
        public string usertype
        {
            get{return _usertype;}
            set
            {
                foreach (UserType u in Enum.GetValues(typeof(UserType)))
                {
                    if (value.Equals(u.ToString()))
                    {
                        _usertype = value;
                        return;
                    }
                }
            }
        }

        public bool agree { get; set; }

        public string ErrMessage { get; set; }
    }
}